package com.yanqu.road.server.cmd.activity.douluodalu;

import com.yanqu.road.entity.activity.douluodalu.data.DouLuoDaLuUserData;
import com.yanqu.road.pb.activity.douluodalu.DouLuoDaLuProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.douluodalu.CrossDouLouDaLuActivity;
import com.yanqu.road.server.manager.douluodalu.CrossDouLuoDaLuMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_DOU_LUO_DA_LU_EXIT,desc = "退出活动")
public class CrossDouLuoDaLuExitViewCmd extends CrossUnionCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        DouLuoDaLuProto.DouLuoDaLuCommonCrossReqMsg crossReq = DouLuoDaLuProto.DouLuoDaLuCommonCrossReqMsg.parseFrom(packet.getBytes());
        CrossDouLouDaLuActivity activity = CrossDouLuoDaLuMgr.getActivityOrNull(crossReq.getActivityId(), groupId);
        if(activity != null){
            DouLuoDaLuUserData userData = activity.getAllUserMap().get(packet.getPlayerId());
            if(userData != null){
                userData.setEntry(false);
            }
        }
    }

    @Override
    public void sendData() {

    }
}
